/**
 * @param {number} n
 * @param {number[][]} mines
 * @return {number}
 */
var orderOfLargestPlusSign = function (n, mines) {
  const grid = new Array(n).fill(0).map(() => new Array(n).fill(1))
  for (const [x, y] of mines) {
    grid[x][y] = 0
  }
  let max = 0
  for (let x = 0; x < n; x++) {
    for (let y = 0; y < n; y++) {
      let left = 0,
        right = 0,
        top = 0,
        bottom = 0
      while (y + left >= 0 && grid[x][y + left] !== 0) left--
      while (y + right < n && grid[x][y + right] !== 0) right++
      while (x + top >= 0 && grid[x + top][y] !== 0) top--
      while (x + bottom < n && grid[x + bottom][y] !== 0) bottom++
      max = Math.max(max, Math.min(-left, right, -top, bottom))
    }
  }
  return max
}

orderOfLargestPlusSign(3,[[1,1]])
